package br.com.webhomesites.locacao.presenter;

import br.com.webhomesites.locacao.contracts.IDevolucaoTotComRenovView;
import br.com.webhomesites.locacao.model.DevolucaoBO;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DevolucaoTotComRenovPresenterActionListeners {

    static class ConfirmarActionListener implements ActionListener {

        private DevolucaoTotComRenovPresenter presenter;

        public ConfirmarActionListener(DevolucaoTotComRenovPresenter presenter) {
            this.presenter = presenter;
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            presenter.setOperacao(presenter.CONFIRMAR_STRATEGY);
            presenter.getOperacao().execute();
            presenter.habilitarEdicao(true);

            IDevolucaoTotComRenovView view = (IDevolucaoTotComRenovView) presenter.getView();

            view.enableBtnConfirmar(false);
            view.enableBtnRecibo(true);
            view.enableBtnCancelar(false);
            //view.enableBtnAlterar(true); 

        }
    }
    static class CancelarActionListener implements ActionListener {

        private DevolucaoTotComRenovPresenter presenter;

        public CancelarActionListener(DevolucaoTotComRenovPresenter presenter) {
            this.presenter = presenter;
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            presenter.setOperacao(presenter.CONFIRMAR_STRATEGY);
            presenter.habilitarEdicao(true);

            IDevolucaoTotComRenovView view = (IDevolucaoTotComRenovView) presenter.getView();

            
//            view.enableBtnInserirItem(true);
//            view.enableBtnRemoverItem(true);
//            view.enableBtnCancelarLocacao(true);
//            view.enableBtnSalvarLocacao(true);
//            //view.enableBtnAlterar(true); 

        }
    }

    static class ReciboActionListener implements ActionListener {

        private DevolucaoTotComRenovPresenter presenter;

        public ReciboActionListener(DevolucaoTotComRenovPresenter presenter) {
            this.presenter = presenter;
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            presenter.setOperacao(presenter.CONFIRMAR_STRATEGY);
            presenter.habilitarEdicao(true);

            IDevolucaoTotComRenovView view = (IDevolucaoTotComRenovView) presenter.getView();

//            view.enableBtnInserirItem(true);
//            view.enableBtnRemoverItem(true);
//            view.enableBtnCancelarLocacao(true);
//            view.enableBtnSalvarLocacao(true);
//            //view.enableBtnAlterar(true); 

        }
    }
static class EnterListener implements ActionListener {

        private DevolucaoTotComRenovPresenter devolucaoTotComRenovPresenter;

        public EnterListener(DevolucaoTotComRenovPresenter devolucaoTotComRenovPresenter) {
            this.devolucaoTotComRenovPresenter = devolucaoTotComRenovPresenter;
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            DevolucaoBO devolucaoBO = new DevolucaoBO();
            double valorPagar = devolucaoBO.calcularValorPagar(devolucaoTotComRenovPresenter.getView().getValorTotalPagar(),devolucaoTotComRenovPresenter.getView().getValorDescontoValor(), devolucaoTotComRenovPresenter.getView().getValorDescontoValor(), "valor");
            //devolucaoTotComRenovPresenter.getView().setValorTotalPagar(valorPagar);
            devolucaoTotComRenovPresenter.getView().setBtnConfirmarRequestFocus(true);
            //locacaoBO.setCalcDataPrevDevolucao(locacaoPresenter);
            //System.out.println("Passou na ação");
        }
    }
    
    
}
